<?php

require '../conn.php';

require 'config.php';

require '../inc/function.php';

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<title></title>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<link rel="stylesheet" href="../css/admin.css" type="text/css" />

<script type="text/javascript" src="inc/function.js"></script>

</head>

<body>

<?php

switch($act){

case 'delete':

	mysql_query('delete from '.$language.'_news where n_id='.$id);

	Msg('','Referer');

	break;

case 'deletes':

	DeleteDatas('delete from '.$language.'_news where n_id');

	break;

case 'index';

	mysql_query('update '.$language.'_news set n_index=1 where n_id='.$id);

	Msg('','Referer');

	break;

case 'unindex':

	mysql_query('update '.$language.'_news set n_index=0 where n_id='.$id);

	Msg('','Referer');

	break;

}

?>

<div id="container">

	<input type="text" id="search_key" class="search_input" size="30" value="<?php echo  $search_key ?>" />

	<input type="button" name="button" class="search_button" value="搜 索" onclick="location.href='?search_key='+$('search_key').value" />

	<?php

	$str='';

	$str.='&nbsp;&nbsp;';

	$str.='分类查看：<select id="n_class" class="input_selects" onchange="ChangeClass(this.value);"><option value="">请选择</option>';

	$query=mysql_query('select * from '.$language.'_news_class where n_sid=0 order by n_order,n_id');

	if (mysql_num_rows($query)>0){

	while($row=mysql_fetch_array($query)){

		$str.='<option value="'.$row['n_id'].'">'.$row['n_name'].'</option>';

	}

	}

	$str.='</select>';

	if ($meter!=''){

		$str.='<script type="text/javascript">$("n_class").value="'.$meter.'";</script>';

		$sqls=' and n_class='.$meter;

	}

	if ($search_key!='') $sqls=" and n_title like '%{$search_key}%'";

	echo $str;

	?>

	<div class="view" style="margin-top:5px;">

		<h1>新闻管理<a href="javascript:location.reload();">刷新</a></h1>

		<form name="form1" id="form1" method="post" action="?act=deletes&<?php echo $urls ?>">

	    <table width="100%" border="0" cellpadding="0" cellspacing="0">

        	<tr class="v_title">

            	<td width="7%">ID号</td>

                <td width="13%">新闻分类</td>

				<td width="41%">新闻标题</td>
   
                <td width="9%">发布时间</td>

				<td width="18%">操作</td>

        	</tr>

			<?php

			$str='';

			$page_size=15;

			$page_sql='select n_id,n_class,n_index,n_order,n_title,n_date from '.$language.'_news where 1=1'.$sqls.' order by n_order,n_id';

			$page_count=GetPageCount($page_size,$page_sql);

			if ($page>$page_count) $page=$page_count;

			$page_number=($page-1)*$page_size;

			$query=mysql_query($page_sql." limit $page_number,$page_size");

			if (mysql_num_rows($query)>0){

			while($row=mysql_fetch_array($query)){

				$str.='<tr onmouseover="this.className=\'view_trover\';" onmouseout="this.className=\'view_trout\';">';

				$str.='<td><input type="checkbox" name="checkbox[]" value="'.$row['n_id'].'" align="absmiddle" />&nbsp;'.$row['n_id'].'</td>';

				$str.='<td>'.RsField('select n_name from '.$language.'_news_class where n_id='.$row['n_class']).'</td>';

				$str.='<td><a href="../shownews.php?id='.$row['n_id'].'" target="_blank">'.$row['n_title'].'</a></td>';

  

				$str.='<td>'.date('Y-m-d',strtotime($row['n_date'])).'</td>';

				$str.='<td><a href="news_modify.php?'.$urls.'&id='.$row['n_id'].'">修改</a> | <a href="?act=delete&id='.$row['n_id'].'" onclick="return ConfirmDel();">删除</a></td>';

				$str.='</tr>';

			}

			}

			else {

				$page_show=false;

			}

			echo $str;

			?>

		</table>

		</form>

		<?php if($page_show) echo ShowPage($page,$page_size,$page_sql); ?>

	</div>

</div>

</body>

</html>